﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FanaticRock.Core.Helpers
{
    ///<summary>文件夹的相关工具类。</summary>
    public static class DirectoryHelper
    {
        ///<summary>可以遵循多个条件获得文件，关系为 OR</summary>
        public static IEnumerable<string> GetFiles(string path, SearchOption option, params string[] filters)
        {
            var list = new List<string>();
            if (filters == null) return list;
            if (filters.Length == 0) return list;

            foreach (var filterItem in filters)
            {
                var result = Directory.GetFiles(path, filterItem, option);
                if (result == null) continue;
                if (result.Length == 0) continue;
                list.AddRange(result);
            }

            return list.Distinct().ToArray();
        }
    }
}
